import 'dart:convert';

import 'package:flutter/services.dart' show rootBundle;

import '../constant/constant.dart';

/// todo: 读取本地json文件
/// [jsonName] json名称
Future<Map<String, dynamic>> getLocalJson(String jsonName) async {
  Map<String, dynamic> map = jsonDecode(await rootBundle.loadString(Constant.jsonPath + jsonName));
  return map;
}

/// todo: 读取本地图片文件
/// [imgName] 图片名称
String getLocalImg(String imgName) => Constant.imagesPath + imgName;

/// todo: 读取本地文件
/// [pathFileName] 完整路径
Future<Map<String, dynamic>> getLocalFile(String pathFileName) async {
  Map<String, dynamic> map = jsonDecode(await rootBundle.loadString(pathFileName));
  return map;
}
